package org.carl.base.feishu.bot.config;

import org.carl.base.feishu.bot.annotation.EnableFeiShubot;
import org.carl.base.feishu.bot.aspectj.FeiShuNotifyAspect;
import org.carl.base.feishu.bot.bean.FeiShubot;
import org.carl.base.feishu.bot.service.FeiShuBotService;
import org.carl.base.feishu.bot.service.impl.FeiShuBotServiceImpl;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 飞书配置文件
 *
 * @author Carl
 */
@ConditionalOnBean(annotation = EnableFeiShubot.class)
@Configuration
@AutoConfigureOrder
public class FeiShuBotConfig {

    @Bean
    @ConfigurationProperties("carl.feishu")
    public FeiShubot feiShubot() {
        return new FeiShubot();
    }

    @Bean
    @ConditionalOnBean(FeiShubot.class)
    public FeiShuBotService feiShuBotService() {
        return new FeiShuBotServiceImpl();
    }

    @Bean
    @ConditionalOnBean(FeiShubot.class)
    public FeiShuNotifyAspect feiShuNotifyAspect() {
        return new FeiShuNotifyAspect();
    }
}
